/**
 * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
 * and/or other contributors as indicated by the @authors tag. See the
 * copyright.txt file in the distribution for a full listing of all
 * contributors.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mycompany.mapper;

import com.mycompany.mapper.util.FirstElement;
import com.mycompany.mapper.util.IterableNonInterableUtil;
import com.mycompany.mapper.util.LastElement;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;


@Mapper(uses = IterableNonInterableUtil.class)
public interface SourceTargetMapper {

    SourceTargetMapper MAPPER = Mappers.getMapper(SourceTargetMapper.class);

    @Mapping(source = "myIntegers", target = "myInteger", qualifiedBy = FirstElement.class)
    @Mapping(source = "myStrings", target = "myString", qualifiedBy = LastElement.class)
    Target toTarget(Source s);

    @Mapping(source = "myIntegers", target = "myInteger", qualifiedBy = FirstElement.class)
    @Mapping(source = "myStrings", target = "myString", qualifiedBy = LastElement.class)
    @InheritConfiguration
    void resetTarget(Source source, @MappingTarget Target target);


    // @Mapping( source = "myInteger", target = "myIntegers", qualifiedBy = CollectElement.class )
    // @Mapping( source = "myString", target = "myStrings", qualifiedBy = CollectElement.class )
    @Mapping(source = "myInteger", target = "myIntegers", qualifiedByName = "collectToList")
    @Mapping(source = "myString", target = "myStrings", qualifiedByName = "collectToList")
    @InheritInverseConfiguration(name = "toTarget")
    Source fromTarget(Target customer);

}
